(ns webcrawler.gui
(:use [clojure.test])
(:use [webcrawler.core])
(:use [webcrawler.test.testcore]))

(import '(javax.swing JFrame JPanel JButton))
(import '(java.awt BorderLayout))
(import 'javax.swing.JOptionPane)
(import 'java.awt.event.ActionListener)

(def button1 (JButton. "Important info"))
(def button2 (JButton. "Run Tests!"))

(defn -main 
	[]

(def panel (doto (JPanel. (BorderLayout. ) )
	   (.add button1 BorderLayout/PAGE_END)
	   (.add button2 BorderLayout/CENTER)))
(def frame (doto (JFrame. "Web crawler says Hi!")
             (.setSize 300 300)
	     ;(.pack)
             (.setContentPane panel)
             (.setVisible true))))

(defn show-info []
  (JOptionPane/showMessageDialog
    nil "The most important generated file is: pdfs-file.txt" "Important Info"
    JOptionPane/INFORMATION_MESSAGE))


(def act (proxy [ActionListener] []
           (actionPerformed [event] (show-info))))

(.addActionListener button1 act)


(def act2 (proxy [ActionListener] []
           (actionPerformed [event] (run-tests 'webcrawler.test.testcore))))

(.addActionListener button2 act2)
